//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.ryzom.nel.misc;

public class CPolygon2D {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CPolygon2D(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CPolygon2D obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CPolygon2D(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public void setVertices(SWIGTYPE_p_std__vectorT_NLMISC__CVector2f_t value) {
    nelmiscJNI.CPolygon2D_Vertices_set(swigCPtr, this, SWIGTYPE_p_std__vectorT_NLMISC__CVector2f_t.getCPtr(value));
  }

  public SWIGTYPE_p_std__vectorT_NLMISC__CVector2f_t getVertices() {
    long cPtr = nelmiscJNI.CPolygon2D_Vertices_get(swigCPtr, this);
    return (cPtr == 0) ? null : new SWIGTYPE_p_std__vectorT_NLMISC__CVector2f_t(cPtr, false);
  }

  public CPolygon2D() {
    this(nelmiscJNI.new_CPolygon2D__SWIG_0(), true);
  }

  public void swap(CPolygon2D other) {
    nelmiscJNI.CPolygon2D_swap(swigCPtr, this, CPolygon2D.getCPtr(other), other);
  }

  public CPolygon2D(CPolygon src, CMatrix projMat) {
    this(nelmiscJNI.new_CPolygon2D__SWIG_1(CPolygon.getCPtr(src), src, CMatrix.getCPtr(projMat), projMat), true);
  }

  public CPolygon2D(CPolygon src) {
    this(nelmiscJNI.new_CPolygon2D__SWIG_2(CPolygon.getCPtr(src), src), true);
  }

  public void fromPolygon(CPolygon src, CMatrix projMat) {
    nelmiscJNI.CPolygon2D_fromPolygon__SWIG_0(swigCPtr, this, CPolygon.getCPtr(src), src, CMatrix.getCPtr(projMat), projMat);
  }

  public void fromPolygon(CPolygon src) {
    nelmiscJNI.CPolygon2D_fromPolygon__SWIG_1(swigCPtr, this, CPolygon.getCPtr(src), src);
  }

  public CPolygon2D(CTriangle tri, CMatrix projMat) {
    this(nelmiscJNI.new_CPolygon2D__SWIG_3(CTriangle.getCPtr(tri), tri, CMatrix.getCPtr(projMat), projMat), true);
  }

  public CPolygon2D(CTriangle tri) {
    this(nelmiscJNI.new_CPolygon2D__SWIG_4(CTriangle.getCPtr(tri), tri), true);
  }

  public boolean isConvex() {
    return nelmiscJNI.CPolygon2D_isConvex(swigCPtr, this);
  }

  public void buildConvexHull(CPolygon2D dest) {
    nelmiscJNI.CPolygon2D_buildConvexHull(swigCPtr, this, CPolygon2D.getCPtr(dest), dest);
  }

  public void getBestTriplet(SWIGTYPE_p_unsigned_int index0, SWIGTYPE_p_unsigned_int index1, SWIGTYPE_p_unsigned_int index2) {
    nelmiscJNI.CPolygon2D_getBestTriplet(swigCPtr, this, SWIGTYPE_p_unsigned_int.getCPtr(index0), SWIGTYPE_p_unsigned_int.getCPtr(index1), SWIGTYPE_p_unsigned_int.getCPtr(index2));
  }

  public void serial(IStream f) {
    nelmiscJNI.CPolygon2D_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public void computeBorders(SWIGTYPE_p_std__vectorT_std__pairT_int_int_t_t borders, SWIGTYPE_p_int minimumY) {
    nelmiscJNI.CPolygon2D_computeBorders(swigCPtr, this, SWIGTYPE_p_std__vectorT_std__pairT_int_int_t_t.getCPtr(borders), SWIGTYPE_p_int.getCPtr(minimumY));
  }

  public void computeOuterBorders(SWIGTYPE_p_std__vectorT_std__pairT_int_int_t_t borders, SWIGTYPE_p_int minimumY) {
    nelmiscJNI.CPolygon2D_computeOuterBorders(swigCPtr, this, SWIGTYPE_p_std__vectorT_std__pairT_int_int_t_t.getCPtr(borders), SWIGTYPE_p_int.getCPtr(minimumY));
  }

  public void computeInnerBorders(SWIGTYPE_p_std__vectorT_std__pairT_int_int_t_t borders, SWIGTYPE_p_int minimumY) {
    nelmiscJNI.CPolygon2D_computeInnerBorders(swigCPtr, this, SWIGTYPE_p_std__vectorT_std__pairT_int_int_t_t.getCPtr(borders), SWIGTYPE_p_int.getCPtr(minimumY));
  }

  public boolean intersect(CPolygon2D other) {
    return nelmiscJNI.CPolygon2D_intersect(swigCPtr, this, CPolygon2D.getCPtr(other), other);
  }

  public boolean contains(CVector2f p, boolean hintIsConvex) {
    return nelmiscJNI.CPolygon2D_contains__SWIG_0(swigCPtr, this, CVector2f.getCPtr(p), p, hintIsConvex);
  }

  public boolean contains(CVector2f p) {
    return nelmiscJNI.CPolygon2D_contains__SWIG_1(swigCPtr, this, CVector2f.getCPtr(p), p);
  }

  public boolean getNonNullSeg(SWIGTYPE_p_unsigned_int seg) {
    return nelmiscJNI.CPolygon2D_getNonNullSeg(swigCPtr, this, SWIGTYPE_p_unsigned_int.getCPtr(seg));
  }

  public void getLineEquation(long index, SWIGTYPE_p_float a, SWIGTYPE_p_float b, SWIGTYPE_p_float c) {
    nelmiscJNI.CPolygon2D_getLineEquation(swigCPtr, this, index, SWIGTYPE_p_float.getCPtr(a), SWIGTYPE_p_float.getCPtr(b), SWIGTYPE_p_float.getCPtr(c));
  }

  public boolean isCCWOriented() {
    return nelmiscJNI.CPolygon2D_isCCWOriented(swigCPtr, this);
  }

  public void getBoundingRect(CVector2f minCorner, CVector2f maxCorner) {
    nelmiscJNI.CPolygon2D_getBoundingRect(swigCPtr, this, CVector2f.getCPtr(minCorner), minCorner, CVector2f.getCPtr(maxCorner), maxCorner);
  }

  public boolean selfIntersect() {
    return nelmiscJNI.CPolygon2D_selfIntersect(swigCPtr, this);
  }

}
